package com.dayi.fragment.child;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dayi.R;
import com.dayi.R2;
import com.dayi.bean.SiXueBean;
import com.dayi.utils.pop.ZoomImagePopupUtils;
import com.lib.fastkit.views.recyclerview.tool.MyLinearLayoutManager;
import com.lib.fastkit.views.recyclerview.zhanghongyang.base.ViewHolder;
import com.lib.framework.component.interceptor.GroupUtils;
import com.lib.ui.adapter.BaseAdapter;
import com.lib.ui.fragment.BaseAppFragment;
import com.lihang.ShadowLayout;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

public class TeacherAnswerListFragment extends BaseAppFragment {

    @BindView(R2.id.rv_ques_list)
    RecyclerView rvQuesList;

    HomeAdapter homeAdapter;

    private List<SiXueBean.ObjBean.QuestionListBean> answerList = new ArrayList<>();

    @Override
    protected void onCreateView(View view, Bundle savedInstanceState) {

        initView();

        initListData();

    }

    private void initView() {


    }

    public void initListData() {

        SiXueBean.ObjBean.QuestionListBean objBean1 = new SiXueBean.ObjBean.QuestionListBean();
        objBean1.setCurrent_value(10);
        objBean1.setDiscount_text("六年级语文");

        SiXueBean.ObjBean.QuestionListBean objBean2 = new SiXueBean.ObjBean.QuestionListBean();
        objBean2.setCurrent_value(15);
        objBean2.setDiscount_text("高一英语");

        answerList.add(objBean1);
        answerList.add(objBean2);

        homeAdapter = new HomeAdapter(getActivity(), answerList);
        MyLinearLayoutManager manager = new MyLinearLayoutManager(getActivity());
        rvQuesList.setLayoutManager(manager);
        rvQuesList.setAdapter(homeAdapter);

    }


    @Override
    protected int getLayoutId() {
        return R.layout.fragment_teacher_answer;
    }


    private class HomeAdapter extends BaseAdapter<SiXueBean.ObjBean.QuestionListBean> {

        public HomeAdapter(Context context, List<SiXueBean.ObjBean.QuestionListBean> mData) {
            super(context, mData);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_teacher_answer;
        }

        @Override
        protected void toBindViewHolder(ViewHolder holder, final int position, final List<SiXueBean.ObjBean.QuestionListBean> mData) {
            /**
             * 问答第一张图
             *
             */
            ImageView iv_ques = holder.getView(R.id.iv_ques);
            TextView tv_money = holder.getView(R.id.tv_money);
            TextView tvItem = holder.getView(R.id.tv_item);
            ImageView ivTeacher1 = holder.getView(R.id.iv_user_tea1);
            ImageView ivTeacher2 = holder.getView(R.id.iv_user_tea2);

            ShadowLayout cardView = holder.getView(R.id.shadowlayout);

            tv_money.setText(mData.get(position).getCurrent_value() + "");
            tvItem.setText(mData.get(position).getDiscount_text());

            cardView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                }
            });

            iv_ques.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    ZoomImagePopupUtils zoomImagePopupUtils = new ZoomImagePopupUtils(getActivity());
                    zoomImagePopupUtils.setZoomImage("");
                    zoomImagePopupUtils.showAnswerPopuPopu(v);

                }
            });


        }
    }

}
